#include "circulqueue.cpp"
#include <iostream>
#include <unistd.h>
#define PNUM 10
#define CNUM 4

void* procude(void* args)
{
    circulqueue<int> *rq=(circulqueue<int>*)args;
    while(true)
    {
        int x=10;
        rq->Push(x);
        std::cout<<"procude: "<< x <<std::endl;
        sleep(1);
    }
}
void* consume(void* args)
{
    circulqueue<int> *rq=(circulqueue<int>*)args;
    while(true)
    {
        int x=10;
        rq->Pop(&x);
        std::cout<<"consum: "<< x <<std::endl;
        sleep(1);
    }
}
int main()
{
    pthread_t pid[PNUM],cid[CNUM];
    circulqueue<int> *rq = new circulqueue<int>();
    for(int i=0;i<PNUM;i++) pthread_create(pid+i,nullptr,procude,(void*)rq);
    for(int i=0;i<CNUM;i++) pthread_create(cid+i,nullptr,consume,(void*)rq);

    for(int i=0;i<PNUM;i++) pthread_join(pid[i],nullptr);
    for(int i=0;i<CNUM;i++) pthread_join(cid[i],nullptr);

    //delete rq;
    return 0;
}